package com.demo4.component;

import com.demo4.model.Student;
import com.demo4.model.User;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

@Component
public class StudentComponent {

    @Bean
    public Student student1() {
        Student student = new Student();
        student.setId(1);
        student.setName("刘德华");
        return student;
    }

    @Bean
    public Student Student2() {
        Student student = new Student();
        student.setId(2);
        student.setName("张学友");
        return student;
    }


}

@Controller
class UserComponent {

    @Bean
    public User user1() {
       User user = new User();
       user.setId(1);
       user.setName("周杰伦");
       return user;
    }

    @Bean
    public User user2() {
        User user = new User();
        user.setId(2);
        user.setName("林俊杰");
        return user;
    }

}
